fix(doctor): refresh expired access tokens instead of reporting failure#12
Merged
fix(doctor): refresh expired access tokens instead of reporting failure#12
Conversation
…sn't exist) Reported live: \`grounds preview list\` failed with Get "https://forge.grnds.io/v1/preview-envs": dial tcp: lookup forge.grnds.io: no such host The default in DefaultAPIURL was wrong — there is no \`forge.grnds.io\` DNS record. The actual forge ingress is at \`platform.grnds.io\` (managed manually in Cloudflare per platform_dns_manual). Aligns with the grounds-push Gradle plugin's GROUNDS_API_URL fallback which already points to platform.grnds.io. Users who set GROUNDS_API_URL or \`apiUrl:\` in ~/.config/grounds/ config.yaml are unaffected; only those falling back to defaults were hitting NXDOMAIN. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reported live: \`grounds doctor\` kept showing
✗ auth token expired (run 'grounds login')
even though every actual command (\`preview list\`, \`push\`, …) worked
fine. Real commands route through FileTokenSource.Token which
transparently exchanges the refresh_token for a fresh access_token;
doctor was doing a static \`time.Now().After(ExpiresAt)\` check on
the cached access_token and didn't try refreshing.
Keycloak's defaults: access_token ≈ 5 min, refresh_token ≈ 30 d.
That gap meant doctor would report "expired" most of the time the
CLI sat idle, prompting the user to re-login when nothing was
actually wrong.
doctor now mirrors the FileTokenSource flow:
- if access still valid → report it + how long it lasts + when the
refresh expires
- if access expired but refresh still valid → call Refresh, persist,
report success ("refreshed; valid 5m0s")
- if both expired → only then say "session expired"
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Doctor was doing a static check on access_token expiry and missing the refresh_token chain that real commands use.